<?php

# return a Array:
#	start => if it is a startpoint
#	search => user entered searchstring (f.e. a city)
#	latitude
#	longitude
function setCoords ($arrLoca, $startpoint=0) {
	$gmap = new gmap();

	foreach ($arrLoca as $locaIndex => $loca) {
		$loca = trim($loca);

		if (strlen($loca) >= 0) {
			if ($coords = $gmap->getCoords($loca)) {					# fetching Coords
				if ($locaIndex === $startpoint) {						# 0 = Startpoint
					$point[0] = array(
									"start" => TRUE,
									"search" => $loca,
									"latitude" => $coords["latitude"],
									"longitude" => $coords["longitude"]
								);
				}
				else {													# other points
					$point[] = array(
									"start" => FALSE,
									"search" => $loca,
									"latitude" => $coords["latitude"],
									"longitude" => $coords["longitude"]
								);
				}
			}
			else {														# Error for fetching Coords
				$point[] = array(
								"start" => FALSE,
								"search" => $loca,
								"latitude" => FALSE,
								"longitude" => FALSE
							);
			}
		}
	}

	return $point;
}

?>